function timestamp2local(ts) {
    // 比如需要这样的格式 yyyy-MM-dd
    const date = new Date(ts);
    return date.getFullYear() + '-' +
        (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' +
        (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
}

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, '\\$&');
    const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function (from, to) {
    let rest = this.slice((to || from) + 1 || this.length);
    this.length = from < 0 ? this.length + from : from;
    return this.push.apply(this, rest);
};
if (!String.prototype.endsWith) {
    String.prototype.endsWith = function (search, this_len) {
        if (this_len === undefined || this_len > this.length) {
            this_len = this.length;
        }
        return this.substring(this_len - search.length, this_len) === search;
    };
}
if (!String.prototype.startsWith) {
    (function () {
        'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
        const defineProperty = (function () {
            // IE 8 only supports `Object.defineProperty` on DOM elements
            let result;
            try {
                const object = {};
                const $defineProperty = Object.defineProperty;
                result = $defineProperty(object, object, object) && $defineProperty;
            } catch (error) {
            }
            return result;
        }());
        const toString = {}.toString;
        const startsWith = function (search) {
            if (this == null) {
                throw TypeError();
            }
            const string = String(this);
            if (search && toString.call(search) === '[object RegExp]') {
                throw TypeError();
            }
            const stringLength = string.length;
            const searchString = String(search);
            const searchLength = searchString.length;
            const position = arguments.length > 1 ? arguments[1] : undefined;
            // `ToInteger`
            let pos = position ? Number(position) : 0;
            if (pos != pos) { // better `isNaN`
                pos = 0;
            }
            const start = Math.min(Math.max(pos, 0), stringLength);
            // Avoid the `indexOf` call if no match is possible
            if (searchLength + start > stringLength) {
                return false;
            }
            let index = -1;
            while (++index < searchLength) {
                if (string.charCodeAt(start + index) !== searchString.charCodeAt(index)) {
                    return false;
                }
            }
            return true;
        };
        if (defineProperty) {
            defineProperty(String.prototype, 'startsWith', {
                'value': startsWith,
                'configurable': true,
                'writable': true
            });
        } else {
            String.prototype.startsWith = startsWith;
        }
    }());
}
function fileLength2Size(data_length) {
    let size = "";
    if(data_length < 1024) size = '' + data_length + ' B';
    else if(data_length < 1024 * 1024) size = '' + (data_length / 1024).toFixed(2) + ' KB';
    else if(data_length < 1024 * 1024 * 1024) size = '' + (data_length / 1024 / 1024).toFixed(2) + ' MB';
    else if(data_length < 1024 * 1024 * 1024 * 1024) size = '' + (data_length / 1024 / 1024 / 1024).toFixed(2) + ' GB';
    else size = '' + (data_length / 1024 / 1024 / 1024 / 1024).toFixed(2) + ' TB';
    return size;
}
function catEn2Zh(cat_name) {
    if(cat_name === 'package') return '压缩包';
    else if(cat_name === 'video') return '视频'; // video|image|document|music|package|software
    else if(cat_name === 'image') return '图像';
    else if(cat_name === 'document') return '文档';
    else if(cat_name === 'music') return '音乐';
    else if(cat_name === 'software') return '软件';
    else if(cat_name === 'other') return '其他';
}